/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package JET.mygui.interfaces;

import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.JComponent;
import JET.mygui.MyGuiManager;

/**
 * Interface allowing objects to take part in drag and drop mechanism of MyGui.
 * 
 * @author raos
 */
public interface MyGuiDnDReady {

    /**
     * Registers gui manager as object that allows drag and drop mechanism
     * to work with this object.
     *
     * @param manager GuiManager to be registererd in this object.
     */
    public void registerGuiManager(MyGuiManager manager);

    public void dndRemove(Object o);
    /**
     * Returns location on screen of this component.
     * @return Point in creen system where this component is placed.
     */
    public Point getDnDLocationOnScreen();

    /**
     * Component rectangle.
     * @return Rectangle that this component is enclosed in.
     */
    public Rectangle getDnDBounds();
    /**
     * Object implementing this interface should return object that can be
     * picked at location specified by Point p.
     * If there is no object to pick up at point p - null should be returned.
     * Point p is specified in this component local system.
     *
     * @param p Point at which MyGuiManager looks for Component to be picked up
     * @return Child of this component that can be picked up at location p,
     *         or null if there is nothing to be picked.
     */
    public JComponent getObjectToPickAt(Point p);

    /**
     * This method is filter for allowing components drop at specified location.
     * Component implementing this interface can accept or reject drop of a component
     * by implementing this method in a way it likes to manage its space.
     * If component accepts other components to be dropped at some loaction p
     * value true should be returned. If component doesn't accept components
     * or wants to make his parent visible for MyGuiManager through some location
     * - then it returns false.
     *
     * @param p Location at which we test if component accepts other components drops.
     *          Point p is specified in this component local system.
     * @return true - if components can be dropped at specified location,
     *         false - if they can't
     */
    public boolean isValidDropLocation(Point p);

    /**
     * This method is used to filter out objects that are accepted as a drop components.
     *
     * @param o Object to be dropped
     * @return true - if objct is accepted to be dropped, false - if it's not
     */
    public boolean accepts(Object o);

    /**
     * Dropps component at specified location.
     * Component implementing this interface, in this method should add
     * droppedComp to its children list or anywhere where it holds its children.
     *
     * @param Object o component that is dropped
     * @param Point p location at whic droppedComp is dropped onto this component.
     *        Point p is specified in this component local system.
     */
    public abstract boolean dropObjectAt(Object o, Point p);

    /**
     *
     */

    // TODO: add methd that adds drawable object to glass pane which shows future layout
    //       of component that is about to be dropped

    /**
     *
     */
    public MyGuiDnDDrawable getFutureLayoutDrawable(Point p);
}
